/***********************************************
 @Name :        小铭同学
 @Time :        2025-08-15
 @Email :       LiaoMingWJ233@163.com
 @Comment :     功能窗口 电机控制
 @FileName :    widget_funcf_control_motor.cpp
 @Version :     1.0
************************************************/

#include "widget_funcf_control_motor.h"
#include "ui_widget_funcf_control_motor.h"

Widget_funcF_Control_motor::Widget_funcF_Control_motor(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget_funcF_Control_motor)
{
    ui->setupUi(this);
    
    ui->label_4->setText("0 Ang");
    ui->label_4->setFont(QFont("楷体",15));
    ui->label_4->setStyleSheet("color: #e056c4;");
    
    ui->label_3->setText("角度控制");
    ui->label_3->setFont(QFont("楷体",15));
    ui->label_3->setStyleSheet("color: #e056c4;");
    
    ui->label_2->setText("0 RPM");
    ui->label_2->setFont(QFont("楷体",15));
    ui->label_2->setStyleSheet("color: #e056c4;");
    
    ui->label->setText("速度控制");
    ui->label->setFont(QFont("楷体",15));
    ui->label->setStyleSheet("color: #e056c4;");
    
    ui->pushButton_yd->setText("电机原点");
    ui->pushButton_yd->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_sf->setText("电机释放");
    ui->pushButton_sf->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_zs->setText("电机自锁");
    ui->pushButton_zs->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_bj->setText("电机步进");
    ui->pushButton_bj->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_fz->setText("电机反转");
    ui->pushButton_fz->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_zz->setText("电机正转");
    ui->pushButton_zz->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 14px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->label_kz->setText("方向控制");
    ui->label_kz->setFont(QFont("楷体",15));
    ui->label_kz->setStyleSheet("color: #e056c4;");
    
    ui->radioButton_can->setText("CAN");
    ui->radioButton_can->setFont(QFont("楷体",13));
    ui->radioButton_can->setStyleSheet("color: #e056c4;");
    
    ui->radioButton_485->setText("RS485");
    ui->radioButton_485->setFont(QFont("楷体",13));
    ui->radioButton_485->setStyleSheet("color: #e056c4;");
    
    ui->radioButton_232->setText("RS232");
    ui->radioButton_232->setFont(QFont("楷体",13));
    ui->radioButton_232->setStyleSheet("color: #e056c4;");
    
    ui->radioButton_pwm->setText("PWM");
    ui->radioButton_pwm->setFont(QFont("楷体",13));
    ui->radioButton_pwm->setStyleSheet("color: #e056c4;");
    
    ui->label_kh->setText("开环控制");
    ui->label_kh->setFont(QFont("楷体",13));
    ui->label_kh->setStyleSheet("color: #e056c4;");
    
    ui->label_bh->setText("闭环控制");
    ui->label_bh->setFont(QFont("楷体",13));
    ui->label_bh->setStyleSheet("color: #e056c4;");
    
    ui->label_mood->setText("模式选择");
    ui->label_mood->setFont(QFont("楷体",15));
    ui->label_mood->setStyleSheet("color: #e056c4;");
    
    ui->label_6->setText("当前细分 1 细分");
    ui->label_6->setFont(QFont("楷体",10));
    ui->label_6->setStyleSheet("color: #e056c4;");
    
    ui->label_5->setText("细分设定");
    ui->label_5->setFont(QFont("楷体",15));
    ui->label_5->setStyleSheet("color: #e056c4;");
    
    
    ui->lineEdit->setFont(QFont("楷体",10));
    ui->lineEdit->setPlaceholderText("设定细分");
    // 设置样式表
    ui->lineEdit->setStyleSheet(R"(
                            QLineEdit {
                            border: 2px solid #9c27b0;
                            border-radius: 6px;
                            padding: 3px 6px;
                            background-color: white;
                            }
                            QLineEdit:focus {
                            border: 2px solid #7b1fa2;
                            background-color: #f3e5f5;
                            }
                            QLineEdit:disabled {
                            border: 2px solid #e1bee7;
                            background-color: #f5f5f5;
                            }
                            )");
    
    ui->label_bt->setText("工业机器人-六轴控制终端");
    ui->label_bt->setFont(QFont("楷体",30));
    ui->label_bt->setStyleSheet("color: #e056c4;");
    
    // 设置样式表（包含无边框和微软雅黑字体）
    ui->pushButton_dj1->setText("伺服电机 1");
    ui->pushButton_dj1->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_dj2->setText("伺服电机 2");
    ui->pushButton_dj2->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_3->setText("伺服电机 3");
    ui->pushButton_3->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_4->setText("伺服电机 4");
    ui->pushButton_4->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_5->setText("伺服电机 5");
    ui->pushButton_5->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    ui->pushButton_6->setText("伺服电机 6");
    ui->pushButton_6->setStyleSheet(R"(
                          QPushButton {
                          background-color: #4285f4;
                          color: white;
                          border-radius: 15px;
                          border: none;
                          padding: 8px 16px;
                          font-size: 18px;
                          font-weight: bold;
                          font-family: "楷体";
                          }
                          QPushButton:hover {
                          background-color: #3367d6;
                          }
                          QPushButton:pressed {
                          background-color: #2a56c6;
                          }
                          )");
    
    // 设置QDial的样式表
    ui->dial->setStyleSheet("QDial { background-color: #48d1cc; }"); // 中绿松石色
    
    // 设置QDial的样式表
    ui->dial_2->setStyleSheet("QDial { background-color: #48d1cc; }"); // 中绿松石色
    
}

Widget_funcF_Control_motor::~Widget_funcF_Control_motor()
{
    delete ui;
}
